import Config from './config'
export default {
  mergeUrl (url, baseUrl) {
    var urlMer = Config.baseUrl
    if (Config.dev) {
      return urlMer + url
    } else {
      return url
    }
  },
  getImgPath (name) {
    return Config.iconPath + name + '.png'
  },
  getCookie (name) {
    var arr
    var reg=new RegExp('(^| )' + name + '=([^;]*)(;|$)')
    if (arr = document.cookie.match(reg)) {
      return unescape(arr[2])
    } else {
      return null
    } 
  },
  getNode (nodes, id) {
    for (var i=0; i<nodes.length; i++) {
      if (id === nodes[i]['data']['id']) {
        return nodes[i]['data']
      }
    }
  },
  resetLine () {
    return {
      'width': 1,
      'target-arrow-shape': 'triangle',
      'line-color': '#70c3ea',
      'curve-style': 'haystack',
      'label': 'data(label)',
      'haystack-radius': 9,
      'target-arrow-color': '#70c3ea'
    }
  },
  selectLine () {
    return {
      'width': 1,
      'target-arrow-shape': 'triangle',
      'line-color': 'red',
      'curve-style': 'haystack',
      'label': 'data(label)',
      'haystack-radius': 9,
      'target-arrow-color': 'red'
    }
  }
}
